import Vue from 'vue'

let apiFiles = require.context('./module', false, /\.js$/)
let api = {}

apiFiles.keys().reduce((module, modulePath) => {
	let moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
	let fileName = modulePath.replace(/^\.\/(.*)$/, '$1')
	api[moduleName] = require('@/http/module/' + fileName)
	return module
}, {})

Vue.prototype.$api = api